from machine import RTC

__rtc = RTC()
__DATETIME_STRING_TEMPLATE = '%d-%d-%d %d:%d:%d'


class RTC_Helper:
    @staticmethod
    def set_time(year, month, day_of_month, hour, minute, second, microsecond=0, week=0):
        __rtc.datetime((year, month, day_of_month, week, hour, minute, second, microsecond))

    @staticmethod
    def current_time():
        return __rtc.datetime()

    @staticmethod
    def current_time_as_string():
        time = RTC_Helper.current_time()
        year = time[0]
        month = time[1]
        day = time[2]
        hour = time[4]
        minute = time[5]
        second = time[6]
        return __DATETIME_STRING_TEMPLATE % (year, month, day, hour, minute, second)
